package com.guigu.qingcheng.mapper;

import com.guigu.qingcheng.pojo.TbCategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface TbCategoryMapper extends Mapper<TbCategory> {

    @Select("SELECT NAME FROM tb_category WHERE id=#{id}")
    public TbCategory findByIdName(@Param("id") Integer id);

    /*
     * 今日推荐
     * */
    @Select("SELECT spu.id AS spuId,sku.* FROM tb_spu spu INNER JOIN tb_sku sku\n" +
            " WHERE spu.id=sku.spu_id \n" +
            "AND spu.is_marketable='1' \n" +
            "GROUP BY sku.spu_id \n" +
            "ORDER BY RAND() LIMIT 4")
    List<Map> TodayPush();
}